package com.example.myproject.fragment;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.common.IntentUtil;
import com.example.common.ToastUtil;
import com.example.myproject.R;
import com.example.myproject.base.BaseFragment;

/**
 * Created by Administrator on 2018/4/4 0004.
 */

public class MineFragment extends BaseFragment implements View.OnClickListener {

    private Button but_mine_inf;
    private ImageView iv_show_msg;
    private TextView tv_path_show;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_mine, null);
        but_mine_inf = rootView.findViewById(R.id.but_mine_inf);
        iv_show_msg = rootView.findViewById(R.id.iv_show_msg);
        tv_path_show = rootView.findViewById(R.id.tv_path_show);

        but_mine_inf.setOnClickListener(this);
        return rootView;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.but_mine_inf:
                ToastUtil.show(getContext(), "获得文件");
                Intent intent = IntentUtil.intentForFile();
                startActivityForResult(intent, 1);
                break;
            default:
                Log.i("tags", "未标识id");
                break;
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        switch (requestCode) {
            case 1:
                if(resultCode== Activity.RESULT_OK){
                    Uri dataData = data.getData();
                    Log.i("tags","Scheme:"+dataData.getScheme());
                    Log.i("tags","shemeSpecifi:"+dataData.getSchemeSpecificPart());
                    Log.i("tags","Authority:"+dataData.getAuthority());
                    Log.i("tags","host:"+dataData.getHost());
                    Log.i("tags","port:"+dataData.getPort());
                    Log.i("tags","path:"+dataData.getPath());
                    Log.i("tags","query:"+dataData.getQuery());
                    Log.i("tags","fragment:"+dataData.getFragment());
                }
                break;
            default:
                Log.i("tags","未注册id");
                break;
        }

    }
}
